package controller

import (
	"gin_api/app/request"
	"gin_api/app/service"
	"gin_api/core/response"
	"github.com/gin-gonic/gin"
)

type Passport struct {
}

func (p Passport) Login(c *gin.Context) {
	var login request.Login
	err := c.ShouldBind(&login)
	if err != nil {
		response.New(c).FailWithMessage(1001, "无效的参数")
		return
	}

	// 登录验证
	loginResponse, err := service.Auth{}.Login(&login)
	if err != nil {
		response.New(c).FailWithMessage(1001, err.Error())
		return
	}
	response.New(c).SuccessWithData(loginResponse)
}
